<?php
class Ajax extends MD_Controller {
	
    
public function __construct()
{
		
	
    parent::__construct();
    
			/*
			* ******************************************************************
			* CHECK IF MODULE IS INSTALLED PROPERLY
			* ******************************************************************
			*/
			$this->MODULE->config->load('module_config');	
			$short_name = $this->MODULE->config->item('short_name');
			$settings_table = $this->MODULE->config->item('settings_table');	 
			if(!$this->PACKAGE->security->app_modules->module_exist($short_name) || empty($short_name) || empty($settings_table))
			{
				$this->PACKAGE->errors->generate->code("001")->stop();
			}
    
			/*
				* ********************************************
				* LOAD LANGUAGE FILES FOR THIS MODULE ONLY
				* notice that some language files have been
				* loaded within MY_Controller core class
				* and those language files are common for all
				* modules
				* ********************************************
				*/    

			$this->MODULE->lang->load('module_texts',LANGUAGE);

			/*
				* ********************************************
				* LOAD PACKAGES
				* ********************************************
				*/
			$this->PACKAGE->core->packages->add('regional');   
			$this->PACKAGE->core->packages->add('routing');   
      
			/*
			 * ********************************************
			 * LOAD LIBRARIES
			 * ********************************************
			 */

			/*
				* ********************************************
				* LOAD MODELS
				* ********************************************
				*/
			$this->PACKAGE->regional->load->model('countries');
			$this->PACKAGE->regional->load->model('timezone');
						
			$this->MODULE->load->model('module_mod_ratesheets_purchase');
			
  
	}
	
	/**
	 * Insert csv and xls number in DB 
	 */
	public function insert_csv_data()
	{
    $data = array();
    
    $post = json_decode(json_decode($this->input->post('data')));
		
		//print_r($post);
		
		print_r($post); 
		$numbers = $post['csv']; 
		$receivedDate = $post['received_date'];
		$xlsFileName = $post['xls'];
		
    foreach ($numbers as $key=>$item)
    {
      $data[$key] = $numbers->{$key};
    }
   
   die(); 
	 /*
		$response = $this->module_numbering->insertNumbers($data);
		if(true === $response)
		{
			echo 'true| ' . lang('data_insert_in_db');
		} else {
			echo 'false| ' .  lang('data_not_insert_in_db');
		}
	  
	  */
	}
	
} // end of class
?>